// s.r(t),
//   s.d(t, {
//     MaskPass: () => MaskPass,
//     ClearMaskPass: () => ClearMaskPass,
//   });
import { WebGLRenderer, WebGLRenderTarget } from "three"
import WebGLRendererModule from "../module/WebGLRendererModule"
import { Pass } from "./Pass"
export class MaskPass extends Pass {
  scene: THREE.Scene
  camera: THREE.PerspectiveCamera
  inverse: boolean
  constructor(e, t) {
    super()
    this.scene = e
    this.camera = t
    this.clear = !0
    this.needsSwap = !1
    this.inverse = !1
  }
  render(e: WebGLRenderer, t: THREE.RenderTarget, s: THREE.RenderTarget) {
    const r = e.getContext()
    const i = e.state
    let a, h
    i.buffers.color.setMask(!1)
    i.buffers.depth.setMask(!1)
    i.buffers.color.setLocked(!0)
    i.buffers.depth.setLocked(!0)
    this.inverse ? ((a = 0), (h = 1)) : ((a = 1), (h = 0))
    i.buffers.stencil.setTest(!0)
    i.buffers.stencil.setOp(r.REPLACE, r.REPLACE, r.REPLACE)
    i.buffers.stencil.setFunc(r.ALWAYS, a, 4294967295)
    i.buffers.stencil.setClear(h)
    i.buffers.stencil.setLocked(!0)
    e.setRenderTarget(s)
    this.clear && e.clear()
    e.render(this.scene, this.camera)
    e.setRenderTarget(t)
    this.clear && e.clear()
    e.render(this.scene, this.camera)
    i.buffers.color.setLocked(!1)
    i.buffers.depth.setLocked(!1)
    i.buffers.stencil.setLocked(!1)
    i.buffers.stencil.setFunc(r.EQUAL, 1, 4294967295)
    i.buffers.stencil.setOp(r.KEEP, r.KEEP, r.KEEP)
    i.buffers.stencil.setLocked(!0)
  }
}
export class ClearMaskPass extends Pass {
  constructor() {
    super()
    this.needsSwap = !1
  }
  render(e: WebGLRenderer) {
    e.state.buffers.stencil.setLocked(!1)
    e.state.buffers.stencil.setTest(!1)
  }
}
